@extends('backend/layouts/default')
@section('title')
Chỉnh sửa câu hỏi
@stop
@section('content')
<h3><span class="glyphicon glyphicon-pencil"></span> Chỉnh sửa câu hỏi</h3>
<form class="form-horizontal" action="" method="post" accept-charset="utf-8" role="form">
    {{ Form::token() }}
    <input type="hidden" name="data[Question][id]" value="<?= $data['question']->id?>"/>

    <div class="row">
        <div class="col-md-9">
            <div class="form-group {{ $errors->has('title') ? 'error':'' }}">
                <label class="control-label col-sm-4" for="title">
                    Tiêu đề : * 
                </label>

                <div class="col-sm-8">
                    <input class="form-control" type="text" name="data[Question][title]" id="data[Question][title]" value="<?= $data['question']->title ?>"/>
                    <?= $errors->first('title', '<span class="help-inline">:message</span>') ?>
                </div>

            </div>  
            <div class="form-group {{ $errors->has('content') ? 'error':'' }}">
                <label class="control-label col-sm-4" for="title">
                    Nội dung : *
                </label>

                <div class="col-sm-8">
                    <textarea class="form-control" rows="20" name="data[Question][content]"
                              id="data[Question][content]"><?= $data['question']->content ?></textarea>
                              <?= $errors->first('content', '<span class="help-inline">:message</span>') ?>
                </div>

            </div>
            <div class="form-group">
                <label class="control-label col-sm-4">Thể loại </label>

                <div class="col-sm-8">
                    <?= Form::Select('data[Question][category_id]',array('0'=>'Không thuộc danh mục  nào') + $data['categories'], Input::old('data[Question][category_id]', $data['question']['category_id']), array('class' => 'form-control'))
                    ?>
                </div>
            </div> 
            <div class="form-group {{ $errors->has('tag') ? 'error':'' }}">
                <label class="control-label col-sm-4" for="title">
                    Tag
                </label>

                <div class="col-sm-8">
                    <input class="form-control" type="text" name= "data[Tags]" id="data[Tags]" />
                    @if(isset($data['tags']))
                    @foreach($data['tags'] as $tag)
                    <a href="javascript:void(0)" class="btn btn-danger btn-xs">{{$tag->title}}</a>&nbsp;
                    @endforeach
                    @endif
                </div>

            </div>  
            <div class="control-group" align="right">
                <div class="controls">
                    <a class="btn btn-link" href="{{ route('questions') }}">Hủy</a>
                    <button type="submit" class="btn btn-success">Lưu lại</button>
                </div>
            </div>
        </div>
    </div>
</form>
<link href="{{ asset('assets/commons/css/autocomplete.css')}}" rel="stylesheet"/>
<script type="text/javascript" src="{{ asset('assets/commons/js/jquery.mockjax.js')}}"></script>
<script type="text/javascript" src="{{ asset('assets/commons/js/jquery.autocomplete.js') }}"></script>
<script type="text/javascript" src="{{ asset('assets/commons/js/lyric.autocomplete.js') }}"></script>
@stop